package cn.phecda.boot.tenant.web.configuration;

import cn.phecda.boot.tenant.core.annotation.ConditionalOnTenantEnabled;
import cn.phecda.boot.tenant.web.filter.TenantGenericFilterBean;
import cn.phecda.boot.tenant.web.handler.TenantHandlerInterceptor;
import jakarta.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * <p> 租户数据配置 </p>
 *
 * @author : wanpinwei
 */
@Slf4j
@ConditionalOnTenantEnabled
@Configuration(proxyBeanMethods = false)
public class TenantWebConfiguration {

    @PostConstruct
    public void postConstruct() {
        log.info("|Phecda Boot Tenant|- Tenant Web Configuration");
    }

    @Bean
    public TenantGenericFilterBean tenantGenericFilterBean() {
        TenantGenericFilterBean filter = new TenantGenericFilterBean();
        log.trace("|Phecda Boot Tenant|- Tenant Generic FilterBean");
        return filter;
    }

    @Bean
    public TenantHandlerInterceptor tenantHandlerInterceptor() {
        TenantHandlerInterceptor interceptor = new TenantHandlerInterceptor();
        log.trace("|Phecda Boot Tenant|- Tenant Handler Interceptor");
        return interceptor;
    }
}
